<?php
namespace app\servergoods\model;

use \app\manage\model\BaseModel;
// 商品分类模型层
class GoodsCategory extends BaseModel
{
	protected $name = 'goods_category';
    protected $connection = 'db_config_goods';
    protected $autoWriteTimestamp = true;
    protected $dateFormat = 'Y-m-d';
    protected $statusText = [0 => '禁用', 1 => '正常'];
    protected $append = ['status_text','cate_attrs_array'];
    protected $readonly = ['pid'];

    public function getStatusTextAttr($value,$data)
    {
    	return $this->statusText[$data['status']];
    }

    public function getCateAttrsArrayAttr($value,$data)
    {
        if($data['cate_attrs']){
            return explode(",",$data['cate_attrs']);
        }else{
            return '';
        }
        
    }
}
